#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2014-08-22 01:14:23
# @Author  : shitao.tommy (hero007asd@gmail.com)
# @Link    : http://example.org
# @Version : $Id$

# import time
# import base64
# import uuid

def gen_qr(num=1, start=100000000):
    '''生成二维码,考虑使用zfill'''
    # a = int(time.time())
    result = []

    try:
        num = int(num)
    except Exception, e:
        num = 0
    try:
        start = int(start)
    except Exception, e:
        start = 0

    end = start + num

    for i in xrange(start,end):
        # b = '%sH%s' % (a, i)
        c = __padding(i)
        result.append((i,c))
    return result

def gen_url_qr(url, num=1, start=100000000):
    '''生成带地址的二维码'''
    result = []

    try:
        num = int(num)
    except Exception, e:
        num = 0
    try:
        start = int(start)
    except Exception, e:
        start = 0

    end = start + num

    if not url.endswith('/'):
        url = url + '/'

    for i in xrange(start,end):
        # b = '%sH%s' % (a, i)
        c = __padding(i)
        result.append((i,url+c))
    return result

# import short_url
from lib.short_url import encode_url
def __padding(stg):
    # result = short_url.encode_url(stg)
    result = encode_url(stg)
    return result

# print gen_url_qr('http://www.baidu.com')


# import short_url
# url = short_url.encode_url(1000000000000000020183723091312312)
# print url
# print short_url.encode_url(2)

